home *** CD-ROM | disk | FTP | other *** search
- /* Multi-purpose BMTR Installer
-
- Written by Nigel Perry, 1990,1991. This is in the PUBLIC DOMAIN.
-
- */
-
- #include "BMTRconfig.h"
-
- #ifdef XCMD
- #define RSRC
- #include <HyperXCmd.h>
- #endif
-
- #ifdef INIT
- #define RSRC
- #endif
-
- #define _BitMapToRegion 0xA8D7
- #define _Unimplemented 0xA89F
-
- #define NIL ((void *)0)
- #define EMPTY ((char *)0xA02) /* low memory global OneOne */
- /* used for "" and "\p" */
-
- /* struct to match patch header */
- typedef struct
- { int bra_instr;
- long check1, check2;
- } cheader;
-
- #ifdef XCMD
- pascal main(paramPtr) XCmdPtr paramPtr;
- #else
- main()
- #endif
- { register Ptr UNIMPLaddr;
- register cheader **hp;
- #ifdef XCMD
- Handle h;
- register long ans;
- #else
- #ifndef INIT
- /* patcher */
- Str255 msg;
- register msgnum;
- #endif
- #endif
-
- #ifndef RSRC
- /* patcher, use only in Finder */
- InitGraf(&thePort);
- InitFonts();
- FlushEvents(everyEvent,0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NIL);
- InitCursor();
-
- if( CautionAlert(2, NIL) == 1 ) return;
- #endif
- asm
- { move.w #_Unimplemented,d0
- _GetTrapAddress
- move.l a0,UNIMPLaddr
- move.w #_BitMapToRegion,d0
- _GetTrapAddress NEWTOOL
- cmp.l a0,UNIMPLaddr
- #ifdef INIT
- bne.s @systemTrap
- #else
- beq.s @patchit
- cmp.l #'np90',OFFSET(cheader,check1)(a0)
- bne.s @systemTrap
- cmp.l #'juri',OFFSET(cheader,check2)(a0)
- bne.s @systemTrap
- #ifndef XCMD
- ; our trap - remove it
- _RecoverHandle SYS
- _DisposHandle
- move.l UNIMPLaddr,a0
- move.w #_BitMapToRegion,d0
- _SetTrapAddress NEWTOOL
- moveq #2,msgnum
- #else
- move.l #'woz\0',ans
- #endif
- bra.s @display
- patchit:
- #endif
- }
-
- hp = (cheader **)GetNamedResource('TRAP', "\pBitMapToRegion");
- if(hp == NIL) asm
- {
- #ifdef INIT
- move.w #4,-(a7)
- _SysBeep
- bra.s @bombLabel
- #else
- #ifdef XCMD
- move.l #'err\0',ans
- #else
- moveq #4,msgnum
- #endif
- bra.s @display
- #endif
- }
- DetachResource((Handle)hp);
-
- asm
- { move.l hp,a0
- _MoveHHi ; move to top of heap
- _HLock ; and lock it down
- ; SetTrapAddress(_BitMapToRegion, StripAddress(*hp))
- move.l (a0),d0
- _StripAddress
- move.l d0,a0
- move.w #_BitMapToRegion,d0
- _SetTrapAddress NEWTOOL
- #ifndef INIT
- #ifdef XCMD
- move.l #'add\0',ans
- #else
- moveq #1,msgnum
- #endif
- bra.s @display
- #endif
- }
-
- systemTrap:
- #ifdef XCMD
- ans = 'sys\0';
- display:
- asm
- { moveq #4,d0
- _NewHandle
- move.l a0,h
- move.l (a0),a0
- move.l ans,(a0)
- }
- paramPtr->returnValue = h;
- #else
- #ifndef INIT
- msgnum = 3;
- display:
- GetIndString(msg, 1, msgnum);
- ParamText(msg, EMPTY, EMPTY, EMPTY);
- NoteAlert(1, NIL);
- #else /* INIT */
- bombLabel:
- ; /* something must come after label */
- #endif
- #endif
- }